package com.tkjt.pms.modules.report.util;


import com.tkjt.pms.common.utils.IndexRateRepositories;

import java.math.BigDecimal;

public class DeptConstant {
	public static String[] community = { "A01A01A01A01",
			"A01A01A01A02",
			"A01A01A01A03",
			"A01A01A01A04",
			"A01A01A01A05",
			"A01A01A01A06",
			"A01A01A01A07",
			"A01A01A01A08",
			"A01A01A01A09",
			"A01A01A01A10",
			"A01A01A01A11",
			"A01A01A01A12",
			"A01A01A01A13",
			"A01A01A01A14",
			"A01A01A01A15"};
	public static String[] depart = { "A01A01A02A01",
			"A01A01A02A02", 
			"A01A01A02A03", 
			"A01A01A02A04", 
			"A01A01A02A05", 
			"A01A01A02A06", 
			"A01A01A02A07", 
			"A01A01A02A08", 
			"A01A01A02A09", 
			"A01A01A02A10", 
			"A01A01A02A11", 
			"A01A01A02A12",
			"A01A01A02A13",
			"A01A01A02A14",
			"A01A01A02A15"};

	/**
	 * 转换为百分比
	 * @param m
	 * @return
	 */
	public static String getPercent(Double m, String indexFormat) {
		if (m == null) {
			m = 0.0;
		}
		BigDecimal bigDecimal = new BigDecimal(m);
		if(indexFormat.equals("3")){
			BigDecimal temp = bigDecimal.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
			return temp.toString() + "%";
		}else {
			return bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
		}
		/*if (IndexRateRepositories.getIndexRate1(indexValueCode)) {
			//百分比后取整
			BigDecimal temp = bigDecimal.multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP);
			return temp.toString() + "%";
		} else if (IndexRateRepositories.getIndexRate2(indexValueCode)) {
			//百分比后保留一位小数
			BigDecimal temp = bigDecimal.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
			return temp.toString() + "%";
		} else {
			return bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
		}*/

	}
}
